package core;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * Game is the top-level object in the composition of GameObjects.  It 
 * comprises Players, Zones, Cards and Attributes, and represents the 
 * state of the game at a given moment.
 */
public class Game extends GameObject
{	
	/**
	 * Create an instance of a Game object.
	 * @param name A descriptive name for this Game.
	 */
	public Game(String name)
	{
		super(name);
		childrens.add(Collections.unmodifiableList(players));
		childrens.add(Collections.unmodifiableList(zones));
	}

	/**
	 * Adds the given Zone to this Game. 
	 * @param zone A Zone that should exist for this Game.
	 * @return The zone.
	 */
	public Zone addZone(Zone zone) {
		zones.add(zone);
		return zone;
	}

	/**
	 * Add the given Player as a participant in this game.
	 * @param player 
	 * @return The player.
	 */
	public Player addPlayer(Player player) {
		players.add(player);
		return player;
	}

	/**
	 * Obtain the players participating in this game.
	 */
	public List<Player> getPlayers() {
		return Collections.unmodifiableList(players);
	}
	
	/**
	 * Returns this game's zones.
	 */
	public List<Zone> getZones() {
		return Collections.unmodifiableList(zones);
	}

	public String toString() {
		return super.toString() + " players = " + players + " zones = " + zones;
	}

	/** Players participating in this Game */
	private final List<Player> players = new LinkedList<Player>(); 
	/** Zones that make up this Game */
	private final List<Zone> zones = new LinkedList<Zone>();  
}